<template>
	<uni-section title="修改信息" type="line">
		<uni-forms ref="baseForm" :modelValue="baseFormData">
			<uni-forms-item label="原密码" required>
				<uni-easyinput v-model="baseFormData.oldPassword" type="password" placeholder="请输入原密码" />
				
				
			</uni-forms-item>
			<uni-forms-item label="新密码" required>
				<uni-easyinput v-model="baseFormData.password" type="password" placeholder="请输入新密码" />
			</uni-forms-item>
			<uni-forms-item label="确认密码" required>
				<uni-easyinput v-model="baseFormData.copyPassword" type="password" placeholder="请再次输入新密码" />
			</uni-forms-item>
			<view style="display: flex; justify-content: space-around;">
				<van-button type="info" @click="goBack">返回</van-button>
				<van-button type="primary" @click="submit">确认</van-button>
			</view>
		</uni-forms>
	</uni-section>
</template>

<script lang="ts" setup>
	import {
		ref,unref
	} from 'vue';
	import {updatePassword} from '@/api/user'
	const baseFormData = ref < any > ({})
	const goBack = ()=>{
		uni.navigateBack()
	}
	const submit = ()=>{
		updatePassword(unref(baseFormData)).then((res)=>{
			if(res.code===0){
				uni.showToast({
					duration:1000,
					icon:'none',
					title:'修改密码成功'
				})
				setTimeout(()=>{
					uni.navigateBack()
				},1000)
				
			}else{
				uni.showToast({
					duration:1000,
					icon:'none',
					title:res.messgae??'修改密码失败'
				})
			}
		})
	}
</script>

<style>

</style>
